import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

import path from 'path'

function resolve(dir: string) {
  return path.join(__dirname, dir)
}

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue()],
  resolve: {
    alias: {
      '@': resolve('src')
    }
  },
  server: {
    host: '0.0.0.0',
    open: true,
    proxy: {
      '/api': {
        target: 'http://127.0.0.1:3000/api',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, '')
      },
      '/pic': {
        target: 'http://127.0.0.1:3000/pic',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/pic/, '')
      }
    }
  },
  base: './',
  build: {
    chunkSizeWarningLimit: 1000,
    outDir: 'dist',
    assetsDir: 'assets',
    // sourcemap: true,
    minify: 'terser',
    terserOptions: {
        compress: {
            //生产环境时移除console
            drop_console: true,
            drop_debugger: true,
        },
    }
  }
})
